# -*- coding: utf-8 -*-            
# @Author : chenliang
# @Time : 2024/10/31 18:26

import  json
import pandas as pd

import datetime
from Common.business_common_tool import BusinessCommonTools
from Common.get_sql_object import GetSqlObject
from Common.dingtalk import Ding
from datetime import timedelta
from Common.do_mysql import DoMysql

"""
  获取当天数据
"""
# # 获取当前时间
# current_time = datetime.now()
# # 格式化当前日期为 'YYYY-MM-DD'
# formatted_date = current_time.strftime('%Y-%m-%d')

"""
 获取周
"""
def get_current_week():
    fmt = lambda x: datetime.datetime.strftime(x, "%Y-%m-%d")
    today = datetime.date.today()
    monday = today - timedelta(days=today.weekday())
    return [fmt(monday + timedelta(days=i)) for i in range(7)]
data_list = get_current_week()

mysql_source = GetSqlObject.get_instance("PRO")
car_list,car_name,amount_list=BusinessCommonTools().get_car_list('PRO',data_list[0],data_list[-1],mysql_source)
query_consignor_sum,query_consignor_list,query_logistics_line,query_logistics_line_today,query_waybill_end_sum,query_waybill_list_today = BusinessCommonTools().get_consignor_and_cooperation_list('PRO',data_list[0],data_list[-1],mysql_source)


df1 = pd.DataFrame(car_list)
df2 = pd.DataFrame(query_consignor_list)

# 指定要导出的Excel文件名
excel_file = 'File/1.xlsx'
print('as')
print(12)
# 使用ExcelWriter对象
with pd.ExcelWriter(excel_file, engine='xlsxwriter') as writer:
    df1.to_excel(writer, sheet_name='车辆', index=False)
    df2.to_excel(writer, sheet_name='货主', index=False)